package com.qdsgjsfk.vision.ui.dialog;
//
//import android.app.Dialog;
//import android.content.Intent;
//import android.graphics.Canvas;
//import android.graphics.Rect;
//import android.graphics.drawable.ColorDrawable;
//import android.media.Image;
//import android.os.Bundle;
//import android.support.annotation.NonNull;
//import android.support.annotation.Nullable;
//import android.support.v7.widget.GridLayoutManager;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.view.Gravity;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.Window;
//import android.view.WindowManager;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.TextView;
//
//import com.rest.business.RestProxy;
//import com.rest.response.GradeClassResponse;
//import com.rest.response.SchoolResponse;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import io.reactivex.Observer;
//import io.reactivex.disposables.Disposable;
//import qdsg.com.R;
//import qdsg.com.base.BaseDialogFragment;
//import qdsg.com.ui.StudentListActivity;
//
///**
// * Created by HP on 2018/10/5.
// */
//
//public class ClassDialog extends BaseDialogFragment {
//
//    public static ClassDialog newInstance() {
//        return new ClassDialog();
//    }
//
//    private Dialog mDialog;
//    private OnItemClickListener mListener;
//    private ImageView btn_cancel;
//    private EditText edt_age;
//    RecyclerView recyclerView;
//    MyAdapter myAdapter;
//    List<GradeClassResponse.Class> list = new ArrayList<>();
//    public String taskSchoolId = "";
//    public String taskId = "";
//    public String schoolName = "";
//
//    @Override
//    public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                             Bundle savedInstanceState) {
//        View view = inflater.inflate(R.layout.dialog_class, container);
////        btn_confirm = view.findViewById(R.id.btn_confirm);
//        getAllClass();
//        btn_cancel = view.findViewById(R.id.btn_cancel);
//        btn_cancel.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                dismiss();
//            }
//        });
//        recyclerView = view.findViewById(R.id.recyclerView);
//        GridLayoutManager layoutManage = new GridLayoutManager(getActivity(), 3);
//        recyclerView.setLayoutManager(layoutManage);
//        myAdapter = new MyAdapter();
//        recyclerView.setAdapter(myAdapter);
//        layoutManage.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
//            @Override
//            public int getSpanSize(int position) {
//                if (list.get(position).type == 1) {
//                    return 3;
//                } else {
//                    return 1;
//                }
//            }
//        });
//
//        return view;
//    }
//
//    @Override
//    public void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//
//
//    }
//
//    @Override
//    @NonNull
//    public Dialog onCreateDialog(Bundle savedInstanceState) {
//        mDialog = super.onCreateDialog(savedInstanceState);
//        mDialog.setCancelable(false);
//        Window window = mDialog.getWindow();
//        if (window != null) {
//            window.setGravity(Gravity.CENTER);
////            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//            window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
//        }
//        return mDialog;
//    }
//
//
//    @Override
//    public void onActivityCreated(Bundle savedInstanceState) {
//        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
//        super.onActivityCreated(savedInstanceState);
//        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0x00000000));
//        getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
//    }
//
//    public OnItemClickListener getmListener() {
//        return mListener;
//    }
//
//    public void setmListener(OnItemClickListener mListener) {
//        this.mListener = mListener;
//    }
//
//
//    public interface OnItemClickListener {
//
//        void onConfirm(String className);
//    }
//
//    public boolean isShowing() {
//        return mDialog != null && mDialog.isShowing();
//    }
//
//
//    class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//
//        @Override
//        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//            if (viewType == 1) {//1 年纪  0班级
//                return new LetterHolder(getLayoutInflater().inflate(R.layout.item_grade, parent, false));
//            } else if (viewType == 0) {
//                return new StudentHolder(getLayoutInflater().inflate(R.layout.item_class, parent, false));
//            }
//            return null;
//        }
//
//        @Override
//        public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
//            if (holder instanceof LetterHolder) {
//                ((LetterHolder) holder).tv_name.setText(list.get(position).gradeName + "  " + list.get(position).className);
//            }
//            if (holder instanceof StudentHolder) {
//                ((StudentHolder) holder).tv_name.setText(list.get(position).className);
//
//                ((StudentHolder) holder).itemView.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        Intent mIntent = new Intent(getActivity(), StudentListActivity.class);
//                        mIntent.putExtra("classId", list.get(position).id);
//                        mIntent.putExtra("taskId", taskId);
//                        mIntent.putExtra("gradeName", schoolName + "  " + list.get(position).classYear + "  " + list.get(position).className);
//                        startActivity(mIntent);
//                    }
//                });
//            }
//
//        }
//
//        @Override
//        public int getItemCount() {
//            return list.size();
//        }
//
//        @Override
//        public int getItemViewType(int position) {
//            if (list.get(position).type == 1)
//                return 1;
//            else
//                return 0;
//        }
//
//        class StudentHolder extends RecyclerView.ViewHolder {
//            TextView tv_name;
//            ImageView img, img_vision, img_diopter, img_diagnose;
//
//            public StudentHolder(View itemView) {
//                super(itemView);
//                tv_name = itemView.findViewById(R.id.tv_name);
//                img = itemView.findViewById(R.id.img);
//                img_vision = itemView.findViewById(R.id.img_vision);
//                img_diopter = itemView.findViewById(R.id.img_diopter);
//
////                examinationDate = itemView.findViewById(R.id.examinationDate);
//
//            }
//        }
//
//        class LetterHolder extends RecyclerView.ViewHolder {
//            TextView tv_name;
//
//            public LetterHolder(View itemView) {
//                super(itemView);
//                tv_name = itemView.findViewById(R.id.tv_name);
//            }
//        }
//    }
//
//
//    private void getAllClass() {
//        RestProxy.getInstance().getAllClasses(taskSchoolId, PreferencesHelper.getInstance().getString(getActivity(), "token"), taskId, new Observer<GradeClassResponse>() {
//            @Override
//            public void onSubscribe(Disposable d) {
//
//            }
//
//            @Override
//            public void onNext(GradeClassResponse gradeClassResponse) {
//                for (GradeClassResponse.Grade grade : gradeClassResponse.data) {
//                    GradeClassResponse gradRes = new GradeClassResponse();
//                    GradeClassResponse.Class c = gradRes.new Class();
//                    c.className = grade.classYear;
//                    c.gradeName = grade.gradeName;
//                    c.type = 1;
//                    list.add(c);
//                    for (GradeClassResponse.Class classes : grade.classDTOList) {
//                        classes.type = 0;
//                        classes.classYear = grade.classYear;
//                        list.add(classes);
//                    }
//                }
//                myAdapter.notifyDataSetChanged();
//            }
//
//            @Override
//            public void onError(Throwable e) {
//
//            }
//
//            @Override
//            public void onComplete() {
//
//            }
//        });
//    }
//
//
//}
